package com.eduadmin.service;

import com.eduadmin.entity.Grade;
import com.eduadmin.mapper.GradeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class GradeServiceImpl implements IGradeService {

    private final GradeMapper gradeMapper;

    @Autowired
    public GradeServiceImpl(GradeMapper gradeMapper) {
        this.gradeMapper = gradeMapper;
    }

    @Override
    public void addGrades(List<Grade> grades) {
        gradeMapper.insertGrades(grades);
    }

    @Override
    public List<Grade> getAllGrades() {
        return gradeMapper.selectAllGrades();
    }

    public List<Grade> getGradeNameByParam(String gradeDatatableName) {
        return gradeMapper.getGradeNameByParam(gradeDatatableName);
    }

    @Override
    public Grade getGradeByGradeName(String gradeName) {
        return gradeMapper.selectGradeByGradeName(gradeName);
    }

    @Override
    public Long getAllTotal(Map<String, Object> paraMap) {
        return gradeMapper.selectAllTotal(paraMap);
    }

    @Override
    public List<Grade> getAllGradeList(Map<String, Object> paraMap) {
        return gradeMapper.selectAllGradeList(paraMap);
    }

    @Override
    public int newAddGrade(Grade grade) {
        return gradeMapper.insertGrade(grade);
    }

    @Override
    public void updateGrade(Grade grade) {
        gradeMapper.updateGrade(grade);
    }

    @Override
    public int deleteGrade(String idString) {
        return gradeMapper.deleteGrade(idString);
    }
}
